resources used - http://learningtensorflow.com/lesson2/
A simple representation of variables and constants in a tf graph
In [1]:
import tensorflow as tf
x = tf.constant(35, name='x')
y = tf.Variable(x + 5, name='y')
model = tf.global_variables_initializer()
Running the graph in a tf session
In [2]:
with tf.Session() as session:
session.run(model)
print(session.run(y))
In [3]:
import tensorflow as tf
x = tf.Variable(0, name='x')
model = tf.global_variables_initializer()
with tf.Session() as session:
session.run(model)
for i in range(5):
x = x + 1
avg = x/(i+1)
print('x = ',session.run(x))
print('moving avg = ',session.run(avg))